<template>
  <div class="home-banner">
    <!-- elementPlus的组件 -->
    <el-carousel height="500px">
      <el-carousel-item v-for="item in bannerList" :key="item.id">
        <img :src="item.imgUrl" alt="图片加载失败" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script setup>
defineOptions({
  name: "HomeBanner",
});
import { getBannerAPI } from "@/apis/layout";
import { onMounted, ref } from "vue";

const bannerList = ref([]);

onMounted(() => {
  // 获取轮播图数据，参数可以不传，默认是一
  getBannerAPI().then((res) => {
    bannerList.value = res.data.result;
  });
});
</script>

<style scoped lang='scss'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;

  img {
    width: 100%;
    height: 500px;
  }
}
</style>